package com.gxa.modules.deviceManager.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.gxa.common.utils.PageUtils;
import com.gxa.common.utils.Query;
import com.gxa.modules.deviceManager.entity.EquipmentManagement;
import com.gxa.modules.deviceManager.mapper.EquipmentManagementMapper;
import com.gxa.modules.deviceManager.service.EquipmentManagementService;
import org.apache.commons.lang.StringUtils;
import org.springframework.stereotype.Service;

import java.util.Map;

@Service
public class EquipmentManagementServiceImpl extends ServiceImpl<EquipmentManagementMapper, EquipmentManagement> implements EquipmentManagementService {

    @Override
    public PageUtils queryByPage(Map<String, Object> params) {
        String equipmentClassify = (String)params.get("equipmentClassify");
        String equipmentName = (String)params.get("equipmentName");
        String communityId = (String)params.get("communityId");


        IPage<EquipmentManagement> page = this.page(new Query<EquipmentManagement>().getPage(params),
                new QueryWrapper<EquipmentManagement>().like(StringUtils.isNotEmpty(equipmentClassify),"equipment_classify",equipmentClassify)
                        .eq(StringUtils.isNotEmpty(equipmentName),"equipment_name",equipmentName).eq(StringUtils.isNotEmpty(communityId),"community_id",communityId)
                );
        return new PageUtils(page);
    }



}
